/* eslint-disable react/prop-types */
//, PureComponent
// eslint-disable-next-line no-use-before-define
import React, { Component, PureComponent } from 'react'

class ComAA extends PureComponent {
  // shouldComponentUpdate (nextProps, newState) {
  //   console.log(nextProps.countInfo === this.props.countInfo)
  //   console.log(this.props)
  //   return true
  // }

  render () {
    console.log('子组件，更新....')

    return (
      <div>子组件， {this.props.countInfo.a}</div>
    )
  }
}

export default class ComA extends Component {
  state = {
    countInfo: { a: 1, b: 2 },
    age: 18
  }

  changeCount = () => {
    // const newCountInfo = this.state.countInfo
    // newCountInfo.a = 100

    this.setState({
      countInfo: { ...this.state.countInfo, a: 100 }
    })
    // this.setState({ count: this.state.count + 1 })
  }

  render () {
    console.log('父组件更新')
    return (
    <>
    父组件
    <p>{this.state.countInfo.a}</p>

    <button onClick={this.changeCount}>点击修改count</button>

    <ComAA countInfo={this.state.countInfo}/></>
    )
  }
}
